<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>用户注册</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="css/mystyle.css">
	<script type='text/javascript' src='css/validation.js'></script>
	<script type='text/javascript' src='/gserv/dwr/interface/userDaoImpl.js'></script>
  	<script type='text/javascript' src='/gserv/dwr/engine.js'></script>
  	<script type="text/javascript" src='css/js/register.js'></script>
	<script>
		function checkName(userName)
		{
			if(userName!="")
			userDaoImpl.checkName(userName,showCheckName)
			else
			errName.innerHTML=='';
				
		}
		function showCheckName(userName)
		{
			errName.innerHTML=userName?'<img src="css/img/ok.gif" />':'<img src="css/img/error.gif" />用户名已存在!'
			document.getElementById("hname").value=userName?'yes':'no'
			
		}
		function checkEmail(email)
		{	
			var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/; 
			if(pattern.test(email))
				userDaoImpl.checkEmail(email,showCheckEmail)
			else
			{
				errEmail.innerHTML='请正确输入邮箱地址!';
				document.getElementById("hemail").value='no';	
			}	
			
		}
		function showCheckEmail(email)
		{	
			
			errEmail.innerHTML=email?'<img src="css/img/ok.gif" />':'<img src="css/img/error.gif" />邮箱已注册!'
			document.getElementById("hemail").value=email?'yes':'no'
		}
		
	</script>
  </head>
  
  <body>
  <div class="all">
  <jsp:include page="header.jsp"></jsp:include>
   <div class="navigation" align="left"><table width="800px"><tr class="navigation"><td>你所在位置:<a href="gongxu/index.jsp">首页</a>><a>用户注册</a></td></tr></table></div>
  <div id="div" style="width: 800px;border-style: solid;border-width: 1px;">
  	<s:form name="useradd" action="usr_userAdd" method="post" >
  	<table width="100%" align="center">
  	<tr>
  		<td  align="right">登录名:</td>
  		<td align="left"><s:textfield id="userName" name="userInfo.userName" onblur="checkName(this.value)"></s:textfield>
  		</td>
  		<td align="left"><span id="errName" style="color:red"></span></td>
  	</tr>
  	<tr>
  		<td align="right">密码:</td>
  		<td align="left"><s:password  id="userpwd" name="userPwd"></s:password></td>
  		<td><span id="pwd" style="color:red"></span></td>
  	</tr>
  	<tr>
  		<td align="right">确认密码:</td>
  		<td align="left"><input type="password" id="repwd"/></td>
  		<td><span id="errPwd" style="color:red"></span></td>
  	</tr>
  	<tr>
  		<td width="40%" align="right">电子邮箱:</td>
  		<td align="left"><s:textfield id="email" name="userInfo.email" onblur="checkEmail(this.value)">
  		</s:textfield>
  		
  		</td>
  		<td width="40%" align="left"><span id="errEmail" style="color:red"></span></td>
  	</tr>
  	<tr><td colspan="3" align="center"><span id="error" style="color:red"></span></td></tr>
  	<tr>
  		<td colspan="3" align="center"><input type="button" value="注册" onclick="login()"><input type="reset" value="重置" /> </td>
  	</tr>
  	</table>
  	</s:form>
  	<input type="hidden" id="hname" name="hname"/>
  	<input type="hidden" id="hemail" name="hemail"/>
  	</div>
  <jsp:include page="bottom.jsp"></jsp:include>
  </div>
  </body>
</html>
